//
//  HYSearchView.swift
//  weibo-01
//
//  Created by 源 何 on 16/9/22.
//  Copyright © 2016年 何源. All rights reserved.
//

import UIKit

//在自定义控件的声明前面添加 @IBDesginable
@IBDesignable class HYSearchView: UIButton {

    //定义类方法 加载该视图的nib文件
    class func loadSearchView() -> HYSearchView{
        let nib = UINib(nibName: "HYSearchView", bundle: nil)
        let searchView = nib.instantiate(withOwner: nil, options: nil).last as! HYSearchView
        return searchView
    }
    
    //当视图被激活的时候
    override func awakeFromNib() {
        //设置图片的内边距
        self.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0)
        //设置文字的内边距
        self.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0)
        //通过代码的方式设置宽度
        self.bounds.size.width = UIScreen.main.bounds.size.width
        
        //设置圆角方式1
//        self.layer.cornerRadius = 17
//        self.layer.masksToBounds = true
    }
}
